<html golimojo-page-type="tablog">
	<head>
		<title>Tab Log</title>
	</head>
	
	<style>

		.templates
		{
			display: none;
		}
		
		.message
		{
			border-bottom: dashed lightgrey 1px;
			white-space: pre;
			font-family: monospace;
			font-size: 10pt;
		}


	</style>
	
	<script>
		
		var gxPageType = "SystemPage";

		function GolimojoTabLog()
		{
			this.messageTemplate = document.getElementById("message-template");
			this.messageTemplate.id = "";
			
			this.messageBox = document.getElementById("message-box");
			this.messageCount = 0;
		}

		GolimojoTabLog.prototype.createMessageElement = function (msgHtml)
		{
			var messageElem = this.messageTemplate.cloneNode(true);
			messageElem.innerHTML = msgHtml;
			return messageElem;
		}

		GolimojoTabLog.prototype.logHtmlMessage = function (msgHtml)
		{
			var messageElem = this.createMessageElement(msgHtml);
			this.messageBox.appendChild(messageElem);
			messageElem.scrollIntoView(false);
			document.title = "Tab Log: " + (++this.messageCount) + " messages";
		}

		GolimojoTabLog.prototype.logMessage = function (msgText)
		{
			var msgHtml = msgText;
			msgHtml = msgHtml.replace(/&/g, "&amp;");
			msgHtml = msgHtml.replace(/\</g, "&lt;");
			msgHtml = msgHtml.replace(/\>/g, "&gt;");
			this.logHtmlMessage(msgHtml);
		}
		
		window.onload = function ()
		{
			window.golimojoTabLog = new GolimojoTabLog();
		}
		
		window.onunload = function ()
		{
			function createAjaxRequest()
			{
				if (window.XMLHttpRequest != null) return new XMLHttpRequest();
				if (window.ActiveXObject != null) return new ActiveXObject("Microsoft.XMLHTTP");
				throw new Error("XMLHttpRequest is not supported!");
			}

			function handleReadyStateChange()
			{
				alert("yo");
			}

			// Request server shutdown in case we're running a local quick-turnaround test configuration.
			var request = createAjaxRequest();
			request.onreadystatechange = handleReadyStateChange;
			var url = "http://#host#/servlet/shutdown".replace(/#host#/g, document.location.host);
			request.open("GET", url, false);
			request.send("");
		}

	</script>
	
	
	
	<body>
	
		<div class="templates">

			<div id="message-template" class="message">
			</div>
			
		</div>
	
		<div id="message-box">
		
		
		
		</div>

	</body>
</html>
